<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\bootstrap\Modal;
use kartik\grid\GridView;
use johnitvn\ajaxcrud\CrudAsset; 
use johnitvn\ajaxcrud\BulkButtonWidget;
use yii\web\View;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\TaozhuangSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Taozhuangs');
$this->params['breadcrumbs'][] = $this->title;

CrudAsset::register($this);
$this->registerJs('
function generate_qrcode(){	
	var keys = new Array();
	$(".info").each(function(){
		var key = $(this).attr("data-key");
		keys.push(key);
	});
	if(keys.length==""){alert("请勾选套装");return false;}

	$.ajax({
		type:"POST",
		url:"'. Url::to(['taozhuang/generate-qrcode']).'",
		dataType:"json",
		data:{"sids":keys},
		success:function(res){
			alert(res.msg);
			window.location.reload();
		},
		error:function(){
		}
	});
}
		
	',View::POS_END);
?>
<div class="taozhuang-index">
    <div id="ajaxCrudDatatable">
    	<p>
    		 <?php echo Html::button('生成二维码',['class'=>'btn btn-primary','id'=>'generate_qrcode','onclick'=>'generate_qrcode()'])?>
    	</p>
        <?=GridView::widget([
            'id'=>'crud-datatable',
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'pjax'=>true,
            'columns' => require(__DIR__.'/_columns.php'),
            'toolbar'=> [
                ['content'=>
                    /*Html::a('<i class="glyphicon glyphicon-plus"></i>', ['create'],
                    ['role'=>'modal-remote','title'=> 'Create new Taozhuangs','class'=>'btn btn-default']).*/
                    Html::a('<i class="glyphicon glyphicon-repeat"></i>', [''],
                    ['data-pjax'=>1, 'class'=>'btn btn-default', 'title'=>'Reset Grid']).
                    '{toggleData}'.
                    '{export}'
                ],
            ],          
            'striped' => true,
            'condensed' => true,
            'responsive' => true,          
            'panel' => [
                'type' => 'primary', 
                'heading' => '<i class="glyphicon glyphicon-list"></i>'.Yii::t('app', 'Taozhuangs listing'),
                'before'=>'',

            ]
        ])?>
    </div>
</div>
<?php Modal::begin([
    "id"=>"ajaxCrubModal",
    "footer"=>"",// always need it for jquery plugin
])?>
<?php Modal::end(); ?>
